package de.casino;

import java.util.ArrayList;
import java.util.Collection;

public abstract class AbstractStrategy {
   public Collection<Result> run(int spins) {
      Collection<Result> retval = new ArrayList<Result>();
      bankroll = initialBankroll;
      currentBet = startBet;
      for (int i = 0; i < spins; i++) {
         Spin s = spin();
         long preBankroll = bankroll;
         bankroll -= currentBet;

         handleSpin(s);
         retval.add(new Result(s, bankroll - preBankroll, bankroll));
      }

      return retval;
   }

   protected abstract void handleSpin(Spin s);

   protected long bankroll;
   protected int  startBet;
   protected int  tableLimit;
   protected long currentBet;
   private int    initialBankroll;

   public AbstractStrategy(int startMoney, int startBet, int tableLimit) {
      this.initialBankroll = startMoney;
      this.startBet = startBet;
      this.tableLimit = tableLimit;

   }

   protected Spin spin() {
      return new Spin();
   }
}
